package chapter06

/**
 * 面向对象
 * 多态
 * scala中多态 、都是动态的、加载的时候才会找
 * 多态
 */
object Test08_DynamicBind {
  def main(args: Array[String]): Unit = {
    val student: Person8 = new Student8
    println(student.name)
    student.hello()
  }
}


class Person8 {
  val name: String = "person"

  def hello(): Unit = {
    println("hello person")
  }
}


/**
 * scala中实现多态
 * 继承者 必须加 override 覆盖
 * 属性和方法都是动态绑定的
 */

class Student8 extends Person8 {

  //override 重写
  override val name: String = "Student"

  //override 重写
  override def hello(): Unit = {
    println("hello Student")
  }
}

